home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PBLIB1 / UNITS / PBOUT1.PAS < prev    next >
Pascal/Delphi Source File  |  1994-05-03  |  10KB  |  413 lines

  1. {SECTION ..PbOUT1 }
  2. UNIT PbOUT1;
  3.  
  4. INTERFACE
  5.  
  6. uses PbMISC, PbDATA, PbOBJS, PbPARMS;
  7.  
  8. {
  9. Description : Medium level Use of OUT_object
  10.  
  11. Author      : Howard Richoux
  12. Date        : 12/24/93
  13. Last revised:  2/18/94 changed libraries
  14. Application : IBM PC and compatibles, done in Turbo Pascal 7
  15. Status      : Placed in the Public Domain by HNR Software 1/29/1994
  16. Published in: none
  17.  
  18.      OUT is a shell around the OUT_object so that calling
  19. programs don't have to worry about a lot of the details.  They
  20. also don't get much control, just the pre-open variables set
  21. in the program and through PARMS.
  22.  
  23. Through the variables are options for CON/LPT1/file output,
  24.      compressed & landscape printing, headers and footers.
  25.  
  26. Use is:
  27.           StandardOUTInit;
  28.           ...
  29.           OUT(<string>);
  30.           ...
  31.           OUTdone;
  32. }
  33.  
  34. var pCompressed : boolean;
  35. var pLandscape  : boolean;
  36. var pHeader1    : string[50];
  37. var pHeader2    : string[30];
  38. var pHeader3    : string[30];
  39. var pFooter1    : string[30];
  40. var pFooter2    : string[50];
  41. var pPageLabel1 : string[30];
  42. var pPageLabel2 : string[30];
  43. var pPageLabel3 : string[30];
  44.  
  45.  
  46. Procedure OUT(s:string);
  47.              {[OUT] Outputs a string }
  48.  
  49. Procedure OUTChangeAPPEND(fn : string);
  50.              {[OUT] Closes current output file/dev opens a new one APPEND }
  51.  
  52. Procedure OUTChangeREWRITE(fn : string);
  53.              {[OUT] Closes current output file/dev opens a new one CLEARING contents }
  54.  
  55. Function  OUTcompressed : boolean;
  56.              {[OUT] Returns true if output compressed }
  57.  
  58. Function  OUTCurrentLineLen : integer;
  59.              {[OUT] Returns current line length }
  60.  
  61. Function  OUTcurrentPage : integer;
  62.              {[OUT] Returns current page number }
  63.  
  64. Procedure OUTdone;
  65.              {[OUT] Closes output device }
  66.  
  67. Procedure OUTdoneWithPage;
  68.              {[OUT] Next line will go on new page }
  69.  
  70. Procedure OUTFlushJoin(alldone : boolean);
  71.              {[OUT*] Get out of word wrap mode }
  72.  
  73. Procedure OUTJoin(s:string);
  74.              {[OUT*] Outputs a string word wrap if necessary}
  75.  
  76. Function OUTJoinStatus : boolean;
  77.              {[OUT*] returns state of the joinflag}
  78.  
  79. Function  OUTLinesLeft : integer;
  80.              {[OUT] lines left on current page }
  81.  
  82. Procedure OUTNoCR(s:string);
  83.              {[OUT] Outputs a string - NO CR/LF }
  84.  
  85. Procedure OUTSetCompressed;
  86.              {[OUT] Go to Compressed print }
  87.  
  88. Procedure OUTSetHeaders(h1,h2,h3,f1,f2 : string);
  89.              {[OUT*] Sets the headers and footers }
  90.  
  91. Procedure OUTSetIndent( i : integer);
  92.              {[OUT] Extra left space }
  93.  
  94. Procedure OUTSetJoin;
  95.              {[OUT*] Go to line word wrap mode }
  96.  
  97. Procedure OUTSetJoinWidth(w : integer);
  98.              {[OUT*] Set the word wrap line width }
  99.  
  100. Procedure OUTSetLandscape;
  101.              {[OUT] Go to Landscape Mode }
  102.  
  103. Procedure OUTSetLengths(ll,pl : integer);
  104.              {[OUT] Manual override to linelen and pagelen }
  105.  
  106. Procedure OUTSetNoPause;
  107.              {[OUT] Cancels pausing on CRT output }
  108.  
  109. Procedure OUTSetNoPrint;
  110.              {[OUT] Suppress output, keep bookkeeping }
  111.  
  112. Procedure OUTSetPageLabels(p1,p2,p3 : string);
  113.              {[OUT*] Sets the optional strings }
  114.  
  115. Procedure OUTSetPrint;
  116.              {[OUT] Turn printing back on. }
  117.  
  118. Procedure OUTPause;
  119.              {[OUT] Pauses if CRT output. }
  120.  
  121. Procedure StandardOUTInit;
  122.              {[OUT] Support for PbOUT; calls StandardpVarsInit }
  123.  
  124.  
  125. { extra utility procs using PbOUT1 basic calls }
  126.  
  127. Procedure OUTDOSErr(s : string; e : integer);
  128.              {[OUT] Outputs a line containing the DOS error message}
  129.  
  130.  
  131. {SECTION .ZImplementation }
  132. IMPLEMENTATION
  133.  
  134. var Outp        : OUT_object_1;    { All access to Outp via PbOUT calls }
  135.  
  136. {SECTION  AddOUTpVars }
  137. Procedure AddOUTpVars;
  138.      begin
  139.      AddParm(1,'COMPRESSED','NO');
  140.      AddParm(1,'LANDSCAPE','NO');
  141.      AddParm(1,'HEADER1','@DATE|@PROGID|');
  142.      AddParm(1,'HEADER2',' ');
  143.      AddParm(1,'HEADER3','');
  144.      AddParm(1,'FOOTER1','');
  145.      AddParm(1,'FOOTER2','');
  146.      AddParm(1,'LABEL1','');
  147.      AddParm(1,'LABEL2','');
  148.      AddParm(1,'LABEL3','');
  149.      end;
  150.  
  151.  
  152. {SECTION  GetOUTpVars }
  153. Procedure GetOUTpVars;
  154.      begin
  155.      pCompressed := CheckOK('COMPRESSED');
  156.      pLandscape  := CheckOK('LANDSCAPE');
  157.      pHeader1    := GetParmStr('HEADER1');
  158.      pHeader2    := GetParmStr('HEADER2');
  159.      pHeader3    := GetParmStr('HEADER3');
  160.      pFooter1    := GetParmStr('FOOTER1');
  161.      pFooter2    := GetParmStr('FOOTER2');
  162.      pPageLabel1 := GetParmStr('LABEL1');
  163.      pPageLabel2 := GetParmStr('LABEL2');
  164.      pPageLabel3 := GetParmStr('LABEL3');
  165.      end;
  166.  
  167.  
  168. {SECTION  OUT }
  169. Procedure OUT(s:string);
  170.      begin
  171.     { writeln('** ',s,' ** ',outp.llen,' ',outp.currllen,' ',outp.loff,' ',outp.indent);}
  172.      Outp.out(s);
  173.      end;
  174.  
  175.  
  176. {SECTION  OUTChangeAPPEND }
  177. Procedure OUTChangeAPPEND(fn : string);
  178.              {[OUT] Closes current output file/dev opens a new one APPEND }
  179.      begin
  180.      Outp.done;
  181.      pOutFile := fn;
  182.      OUTp.LISTinit(pOutFile,OUT_typAPPEND);
  183.      if pCompressed then OUTp.SetCompressed;
  184.      if pLandscape  then OUTp.SetLandscape;
  185.      OUTp.LISTopen;
  186.      end;
  187.  
  188.  
  189. {SECTION  OUTChangeREWRITE }
  190. Procedure OUTChangeREWRITE(fn : string);
  191.              {[OUT] Closes current output file/dev opens a new one CLEARING contents }
  192.      begin
  193.      Outp.done;
  194.      pOutFile := fn;
  195.      OUTp.LISTinit(pOutFile,OUT_typREWRITE);
  196.      if pCompressed then OUTp.SetCompressed;
  197.      if pLandscape  then OUTp.SetLandscape;
  198.      OUTp.LISTopen;
  199.      end;
  200.  
  201.  
  202. {SECTION  OUTCompressed  }
  203. FunctION  OUTCompressed : boolean;
  204.      begin
  205.      OUTCompressed := Outp.compressed;
  206.      end;
  207.  
  208.  
  209. {SECTION  OUTCurrentLineLen }
  210. Function  OUTCurrentLineLen : integer;
  211.      begin
  212.      OUTCurrentLineLen := Outp.currllen;
  213.      end;
  214.  
  215.  
  216. {SECTION  OUTCurrentPage }
  217. Function  OUTCurrentPage : integer;
  218.      begin
  219.      OUTCurrentPage := Outp.currpage;
  220.      end;
  221.  
  222.  
  223. {SECTION  OUTdone }
  224. Procedure OUTdone;
  225.      begin
  226.      Outp.done;
  227.      end;
  228.  
  229.  
  230. {SECTION  OUTdonewithPage }
  231. Procedure OUTdoneWithPage;
  232.      begin
  233.      Outp.DoneWithPage;
  234.      end;
  235.  
  236.  
  237. {SECTION  OUTFlushJoin }
  238. Procedure OUTFlushJoin(alldone : boolean);
  239.      begin
  240.      Outp.flushjoin(alldone);
  241.      end;
  242.  
  243.  
  244. {SECTION  OUTJoin }
  245. Procedure OUTJoin(s:string);
  246.      begin
  247.      Outp.outjoin(s);
  248.      end;
  249.  
  250.  
  251. {SECTION  OUTLinesLeft }
  252. Function  OUTLinesLeft : integer;
  253.              {[OUT] lines left on current page }
  254.      begin
  255.      OUTLinesLeft := (Outp.plen - Outp.currline) + 1;
  256.      end;
  257.  
  258.  
  259. {SECTION  OUTNoCR }
  260. Procedure OUTNoCR(s:string);
  261.      begin
  262.      Outp.outERRNoCR(s);  { no CR/LF and no bookkeeping }
  263.      end;
  264.  
  265.  
  266. {SECTION  OUTPause }
  267. Procedure OUTPause;
  268.      begin
  269.      Outp.pause;
  270.      end;
  271.  
  272.  
  273. {SECTION  OUTSetHeaders }
  274. Procedure OUTSetHeaders(h1,h2,h3,f1,f2 : string);
  275.      begin
  276.      Outp.SetHeaders(h1,h2,h3,f1,f2);
  277.      end;
  278.  
  279.  
  280. {SECTION  OUTSetCompressed }
  281. Procedure OUTSetCompressed;
  282.      begin
  283.      Outp.SetCompressed;
  284.      end;
  285.  
  286.  
  287. {SECTION  OUTSetIndent }
  288. Procedure OUTSetIndent( i : integer);
  289.      begin
  290.      Outp.SetIndent(i);
  291.      end;
  292.  
  293.  
  294. {SECTION  OUTSetJoin }
  295. Procedure OUTSetJoin;
  296.      begin
  297.      Outp.joinflag := true;
  298.      end;
  299.  
  300.  
  301. {SECTION  OUTSetJoin }
  302. Function OUTJoinStatus : boolean;
  303.      begin
  304.      OutJoinStatus := Outp.joinflag;
  305.      end;
  306.  
  307.  
  308. {SECTION  OUTSetJoinWidth }
  309. Procedure OUTSetJoinWidth(w : integer);
  310.      begin
  311.      if w = 0 then Outp.joinwidth := Outp.currllen
  312.      else Outp.joinwidth := w;
  313.      end;
  314.  
  315.  
  316. {SECTION  OUTSetLandscape }
  317. Procedure OUTSetLandscape;
  318.      begin
  319.      Outp.SetLandscape;
  320.      end;
  321.  
  322.  
  323. {SECTION  OUTSetLengths }
  324. Procedure OUTSetLengths(ll,pl : integer);
  325.      begin
  326.      Outp.llen := ll;
  327.      Outp.plen := pl;
  328.      end;
  329.  
  330.  
  331. {SECTION  OUTSetNoPause }
  332. Procedure OUTSetNoPause;
  333.      begin
  334.      Outp.SetNoPause;
  335.      end;
  336.  
  337.  
  338. {SECTION  OUTSetNoPrint }
  339. Procedure OUTSetNoPrint;
  340.      begin
  341.      Outp.noprint := true;
  342.      end;
  343.  
  344.  
  345. {SECTION  OUTSetPageLabels }
  346. Procedure OUTSetPageLabels(p1,p2,p3 : string);
  347.      begin
  348.      Outp.pagelabel1 := p1;
  349.      Outp.pagelabel2 := p2;
  350.      Outp.pagelabel3 := p3;
  351.      end;
  352.  
  353.  
  354. {SECTION  OUTSetPrint }
  355. Procedure OUTSetPrint;
  356.      begin
  357.      Outp.noprint := false;
  358.      end;
  359.  
  360.  
  361. {SECTION  StandardOutINit }
  362. Procedure StandardOUTInit;
  363.      begin
  364.  
  365.      StandardpVarsInit;    { Picks up the other pVars as well }
  366.      GetOUTpVars;          { OUT specific pVars }
  367.  
  368.      if ScanParms('P') then pOutFile := 'LPT1';
  369.  
  370.      OUTp.LISTinit(pOutFile,OUT_typAPPEND);
  371.      if OUTp.devtyp =OUT_typCRT then
  372.           begin  {CRT is cranked down to nothing }
  373.           OUTp.SetHeaders('','','','','');
  374.           end
  375.      else OUTp.SetHeaders(pHeader1,pHeader2,pHeader3,pFooter1,pFooter2);
  376.      if pCompressed then OUTp.SetCompressed;
  377.      if pLandscape  then OUTp.SetLandscape;
  378.      OUTp.LISTopen;
  379.      end;
  380.  
  381.  
  382.  
  383.  
  384.  
  385. {SECTION  OUTDOSErr }
  386. Procedure OUTDOSErr(s : string; e : integer);
  387. {[OUT] Outputs a line containing the DOS error message}
  388.      begin
  389.      OUT(s+' '+DOSErrStr(e));
  390.      end;
  391.  
  392.  
  393. {SECTION  zPbOUTINit_1 }
  394. Procedure zPbOUTInit_1;
  395.      begin
  396.      pCompressed := false;
  397.      pLandscape  := false;
  398.      pHeader1 := '';
  399.      pHeader2 := '';
  400.      pHeader3 := '';
  401.      pFooter1 := '';
  402.      pFooter2 := '';
  403.      AddOUTpVars;          { OUT specific pVars - this makes sure calling
  404.                              programs can override headers & footers }
  405.      end;
  406.  
  407.  
  408.  
  409. {SECTION zzInitialization }
  410.      begin {initialization}
  411.      zPbOUTInit_1;
  412.      end.
  413.